import { transform } from '@babel/core'
import { complier } from './complier'

/**
 * 代码效果
 * const getUser_post = 'xxx/router/B_user'
 * => const userAuth = 'B_user_router'
 *
 * @param code 传入的要修改代码信息
 * @return 返回的处理过的信息
 */
export const generateCodeByAst: (code: string) => unknown = (code: string) => {
  let astCode = transform(code, {
    plugins: [complier]
  })
  return astCode
}
